﻿@model ConferenceHotelEditModel
@{
	ViewBag.Title = Resources.ConferenceHotelEdit + ConstValues.strDash + ViewBag.ConferenceName;
}
<div id="menuBar" style="height:35px;">
	<div style="float: left; padding: 5px 5px; font-weight: bold; text-align: left;">
		@Resources.HotelName：<input id="searchHotelName" class="easyui-textbox" style="height:27px; width:200px;" />&nbsp;&nbsp;
		<a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-search" onclick="searchData();">@Resources.Search</a>&nbsp;&nbsp;
		@if ((User as ICISPrincipal).IsSSA || (User as ICISPrincipal).CSAList.Contains(Model.ConferenceId) || Utility.HasConferenceRole((User as ICISPrincipal), Model.ConferenceId, ConstValues.FunctionId.ConferenceHotelEdit, RoleType.添加))
		{
			<a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-add" onclick="addData();" plain="true">@Resources.Create</a>
		}
	</div>
	<div class="clear"></div>
</div>
<div id="dataGrid"></div>

@section bodyParts {
<div id="detailWindow" class="easyui-window"
	title="@Resources.ConferenceHotelEdit" data-options="closed:true,minimizable:false,iconCls:'icon-save'"
	style="width:1200px; display:none;">
	<div class="main">
		<div class="box clearfix">
			<h3 id="detailWindowTitle" class="tit01">@Resources.Create</h3>
			<form id="frmDetail" method="post">
				@Html.AntiForgeryToken()
				<table width="100%" height="100%" id="tblDetail" cellpadding="0" cellspacing="1" border="0" class="tastyle01">
					<tr>
						<td style="text-align: right;" class="w1 c1">@Resources.ConferenceName：</td>
						<td style="text-align: left;" class="w2 c2">
							<input id="hidID" name="Id" type="hidden" />
							<input id="hidConferenceId" name="conferenceId" type="hidden" />
							<input id="txtConferenceName" disabled class="easyui-textbox" style="height:27px; width:300px;" value="@ViewBag.ConferenceName">
						</td>
						<td style="text-align: right;" class="w1 c1">@Resources.HotelName：</td>
						<td style="text-align: left;" class="w2 c2">
							<input id="txtHotelName" name="hotelName" class="easyui-textbox" style="height:27px; width:300px;" data-options="required:true,validType:['length[1,100]']">
						</td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c3">@Resources.Address：</td>
						<td style="text-align: left;" class="w2 c4">
							<input id="txtAddress" name="address" class="easyui-textbox" style="height:27px; width:300px;" data-options="required:true,validType:['length[1,200]']">
						</td>
						<td style="text-align: right;" class="w1 c3">@Resources.Telephone：</td>
						<td style="text-align: left;" class="w2 c4">
							<input id="txtTelephone" name="telephone" class="easyui-textbox" style="height:27px; width:300px;" data-options="required:true">
						</td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c1">@Resources.StarLevel：</td>
						<td style="text-align: left;" class="w2 c2">
							<select id="txtStarLevel" name="starLevel" class="easyui-combobox" style="height:27px; width:300px;" data-options="panelHeight:'auto',editable:false">
								<option value="@ConstValues.StarLevel.一星">@Resources.OneStar</option>
								<option value="@ConstValues.StarLevel.二星">@Resources.TwoStar</option>
								<option value="@ConstValues.StarLevel.三星">@Resources.ThreeStar</option>
								<option value="@ConstValues.StarLevel.四星">@Resources.FourStar</option>
								<option value="@ConstValues.StarLevel.五星">@Resources.FiveStar</option>
							</select>
						</td>
						<td style="text-align: right;" class="w1 c1">@Resources.ParkFee：</td>
						<td style="text-align: left;" class="w2 c2">
							<input id="txtParkFee" name="parkFee" class="easyui-textbox" style="height:27px; width:300px;" data-options="validType:['length[1,50]']">
						</td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c3">@Resources.Status：</td>
						<td style="text-align: left;" class="w2 c4">
							<select id="ddlStatus" name="status" class="easyui-combobox" style="height:27px; width:300px" data-options="editable:false,required:true,panelHeight:'auto'">
								<option value="@ConstValues.Status.正常">@Resources.Normal</option>
								<option value="@ConstValues.Status.暂停">@Resources.Pause</option>
							</select>
						</td>
						<td style="text-align: right;" class="w1 c3">@Resources.Sort：</td>
						<td style="text-align: left;" class="w2 c4">
							<input id="txtSort" name="sort" class="easyui-numberbox" style="height:27px; width:300px;" />
						</td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c1">@Resources.Remark：</td>
						<td style="text-align: left;" class="w2 c2" colspan="3">
							<input id="txtRemark" name="remark" class="easyui-textbox" style="height:50px; width:892px;" data-options="multiline:true,validType:['length[1,1000]']" />
						</td>
					</tr>
				</table>
			</form>
			<div class="btnDiv">
				<input type="hidden" id="hdnWindowType" />
				<input type="button" class="gbtn" onclick="saveData();" value="@Resources.Save" />&nbsp;&nbsp;
				<input type="button" class="rbtn" onclick="$('#detailWindow').window('close');" value="@Resources.Cancel" />
			</div>
		</div>
	</div>
</div>
<div id="roomWindow" class="easyui-window"
	title="@Resources.RoomManage" data-options="closed:true,minimizable:false,maximizable:false,iconCls:'icon-save'"
	style="width:1200px; display:none;">
	<div class="main">
		<div class="box clearfix">
			<h3 id="roomWindowTitle" class="tit01" style="text-align:left;"><a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-add" style="background:#919295;color:#000;border:none;margin-left:5px;" onclick="addRoomData();">@Resources.Create</a></h3>
			<div id="roomGrid"></div>
		</div>
	</div>
</div>
<div id="roomEditWindow" class="easyui-window"
	title="@Resources.RoomManage" data-options="closed:true,minimizable:false,iconCls:'icon-save'"
	style="width:1200px; display:none;">
	<div class="main">
		<div class="box clearfix">
			<h3 id="roomEditWindowTitle" class="tit01"></h3>
			<form id="frmRoomDetail" method="post">
				@Html.AntiForgeryToken()
				<table width="100%" height="100%" id="tblDetail" cellpadding="0" cellspacing="1" border="0" class="tastyle01">
					<tr>
						<td style="text-align: right;" class="w1 c1">@Resources.HotelName：</td>
						<td style="text-align: left;" class="w2 c2">
							<input type="hidden" id="hotelID" name="hotelID" />
							<input type="hidden" id="roomID" name="roomID" />
							<input id="txtRoomHotelName" name="roomHotelName" class="easyui-textbox" style="height:27px; width:300px;" disabled>
						</td>
						<td style="text-align: right;" class="w1 c1">@Resources.RoomType：</td>
						<td style="text-align: left;" class="w2 c2">
							<input id="txtRoomType" name="roomType" class="easyui-textbox" style="height:27px; width:300px;" data-options="required:true">
						</td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c3">@Resources.RoomTypeBedNum：</td>
						<td style="text-align: left;" class="w2 c4">
							<select id="txtRoomTypeBedNum" name="roomTypeBedNum" class="easyui-combobox" style="height:27px; width:300px;" data-options="editable:false,required:true,panelHeight:'auto'">
								<option value="@ConstValues.RoomBedCount.One">@ConstValues.RoomBedCount.One</option>
								<option value="@ConstValues.RoomBedCount.Two">@ConstValues.RoomBedCount.Two</option>
							</select>
						</td>
						<td style="text-align: right;" class="w1 c3">@Resources.Currency：</td>
						<td style="text-align: left;" class="w2 c4">
							<select id="txtRoomCurrency" name="roomCurrency" class="easyui-combobox" style="height:27px; width:300px;" data-options="editable:false,required:true,panelHeight:'auto'">
								<option value="@ConstValues.Currency.人民币">@Resources.RMB</option>
								<option value="@ConstValues.Currency.美元">@Resources.Dollar</option>
							</select>
						</td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c1">@Resources.Price1：</td>
						<td style="text-align: left;" class="w2 c2">
							<input id="txtRoomPrice1" name="roomPrice1" class="easyui-numberbox" style="height:27px; width:300px;" data-options="min:0,required:true,precision:2">
						</td>
						<td style="text-align: right;" class="w1 c1">@Resources.Price2：</td>
						<td style="text-align: left;" class="w2 c2">
							<input id="txtRoomPrice2" name="roomPrice2" class="easyui-numberbox" style="height:27px; width:300px;" data-options="min:0,precision:2">
						</td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c3">@Resources.TotalRoomCount：</td>
						<td style="text-align: left;" class="w2 c4">
							<input id="txtRoomTotalRoomCount" name="roomTotalRoomCount" class="easyui-numberbox" style="height:27px; width:300px;" data-options="min:0,required:true">
						</td>
						<td style="text-align: right;" class="w1 c3">@Resources.ConferenceDate：</td>
						<td style="text-align: left;" class="w2 c4">
							<input id="bookingDate" name="bookingDate" class="easyui-datebox" style="height:27px; width:300px;" data-options="editable:false,required:true">
						</td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c1">@Resources.Status：</td>
						<td style="text-align: left;" class="w2 c2">
							<select id="ddlRoomStatus" name="roomStatus" class="easyui-combobox" style="height:27px; width:300px;" data-options="editable:false,required:true,panelHeight:'auto'">
								<option value="@ConstValues.Status.正常">@Resources.Normal</option>
								<option value="@ConstValues.Status.暂停">@Resources.Pause</option>
							</select>
						</td>
						<td style="text-align: right;" class="w1 c1">@Resources.Sort：</td>
						<td style="text-align: left;" class="w2 c2">
							<input id="txtRoomSort" name="roomSort" class="easyui-numberbox" style="height:27px; width:300px;" />
						</td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c3">@Resources.Remark：</td>
						<td style="text-align: left;" class="w2 c4" colspan="3">
							<input id="txtRoomRemark" name="roomRemark" class="easyui-textbox" style="height:50px; width:892px;" data-options="multiline:true,validType:['length[1,100]']" />
						</td>
					</tr>
				</table>
			</form>
			<div class="btnDiv">
				<input type="hidden" id="hdnRoomWindowType" />
				<input type="button" class="gbtn" onclick="saveRoomData();" value="@Resources.Save" />&nbsp;&nbsp;
				<input type="button" class="rbtn" onclick="$('#roomEditWindow').window('close');" value="@Resources.Cancel" />
			</div>					
		</div>
	</div>
</div>
}

@section Scripts {
<script>
	common.setCurrentMenu("ConferenceHotelEdit");
	common.setCurrentParentMenu("#menu_a4");

	$(function () {
		$("#hidConferenceId").val("@Model.ConferenceId");
		$("#searchHotelName").textbox("textbox").bind("keydown", function (e) {
			if (e.keyCode == 13) {
				searchData()
			}
		});

		$("#dataGrid").datagrid({
			url: "@Url.Action(nameof(ConferenceHotelEditController.GetData), nameof(ConferenceHotelEditController).GetControllerName(),new { ConferenceId = Model.ConferenceId })",
			method: "get",
			singleSelect: true,
			nowrap: false,
			pagination: true,
			pageSize: @ConstValues.DefaultGridRows,
			striped: true,
			toolbar: "#toolBar",
			width: $(window).width() - 285,
			height: $(window).height() - 158,
			pageSize: 100,
			pageList: [100, 200, 300, 400, 500],
			frozenColumns: [[
				{ field: "id", hidden: true },
				@if ((User as ICISPrincipal).IsSSA || (User as ICISPrincipal).CSAList.Contains(Model.ConferenceId) ||
					Utility.HasConferenceRole((User as ICISPrincipal), Model.ConferenceId, ConstValues.FunctionId.ConferenceHotelEdit, RoleType.修改) ||
					Utility.HasConferenceRole((User as ICISPrincipal), Model.ConferenceId, ConstValues.FunctionId.ConferenceHotelEdit, RoleType.删除))
				{
					<text>
					{
					        field: "operate", title: "@Resources.Operate", align: "center", width: 200,
					        formatter: function(value, rec) {
					        	var strInfo = "";
					        	var tmp = rec.hotelName.replace(new RegExp("'",'g'),"’").replace(new RegExp('"','g'),"“");
					        	@if ((User as ICISPrincipal).IsSSA || (User as ICISPrincipal).CSAList.Contains(Model.ConferenceId) || Utility.HasConferenceRole((User as ICISPrincipal), Model.ConferenceId, ConstValues.FunctionId.ConferenceHotelEdit, RoleType.修改))
							{
								<text>
					        		strInfo += "<a href='#' style='color:#FF8C00;font-weight:bold;text-decoration:underline;' onclick='roomManage(\""
									+ rec.id + "\",\"" + tmp + "\")'>@Resources.RoomManage</a>";
					        		strInfo += "&nbsp;|&nbsp;";
					        		strInfo += "<a href='#' style='color:#66CDAA;font-weight:bold;text-decoration:underline;' onclick='editData(\""
										+ rec.id + "\")'>@Resources.Modify</a>";
					        		</text>
							}
					        	@if ((User as ICISPrincipal).IsSSA || (User as ICISPrincipal).CSAList.Contains(Model.ConferenceId) || Utility.HasConferenceRole((User as ICISPrincipal), Model.ConferenceId, ConstValues.FunctionId.ConferenceHotelEdit, RoleType.删除))
							{
								<text>
					        		if (strInfo != "") {
					        			strInfo += "&nbsp;|&nbsp;";
					        		}
					        		strInfo += "<a href='#' style='color:#DC143C;font-weight:bold;text-decoration:underline;' onclick='deleteData(\""
										+ rec.id + "\",\"" + tmp + "\")'>@Resources.Delete</a>";
					        		</text>
							}
					        	return strInfo;
					        }
					},
					</text>
				}
				{ field: "hotelName", title: "@Resources.HotelName", align: "center", sortable: true, width: 200 },
			]],
			columns: [[
				{ field: "hotelAddress", title: "@Resources.Address", align: "center", sortable: true, width: 300 },
				{ field: "hotelTel", title: "@Resources.Telephone", align: "center", sortable: true, width: 150 },
				{
					field: "level", title: "@Resources.StarLevel", align: "center",sortable: true, width: 150 ,
                    			formatter: function(value, rec) {
                    				if (value=="@ConstValues.StarLevel.一星") {
                    					return "@Resources.OneStar"
                    				} else if(value=="@ConstValues.StarLevel.二星") {
                    					return "@Resources.TwoStar"
                    				} else if(value=="@ConstValues.StarLevel.三星") {
                    					return "@Resources.ThreeStar"
                    				} else if(value=="@ConstValues.StarLevel.四星") {
                    					return "@Resources.FourStar"
                    				} else if(value=="@ConstValues.StarLevel.五星") {
                    					return "@Resources.FiveStar"
                    				}
                    			}
				},
				{ field: "parkingFee", title: "@Resources.ParkFee", align: "center", sortable: true, width: 150 },
				{
					field: "status", title: "@Resources.Status", align: "center", sortable: true, width: 150,
					formatter: function(value, rec) {
						if (value=="@ConstValues.Status.正常") {
							return "@Resources.Normal"
						} else {
							return "@Resources.Pause"
						}
					}},
				{ field: "sort", title: "@Resources.Sort", align: "center", sortable: true, width: 150 },
				{ field: "remark", title: "@Resources.Remark", align: "center", sortable: true, width: 200 },
				{ field: "creator", title: "@Resources.Creator", align: "center", sortable: true, width: 150 },
				{ field: "createIP", title: "@Resources.CreateIP", align: "center", sortable: true, width: 150 },
				{ field: "createDate", title: "@Resources.CreateDate", align: "center", sortable: true, width: 150 },
			]],
			onBeforeLoad: function(param) {
				param.random = Math.random();
				param.conferenceId = $("#hidConferenceId").val();
			}
		});

		$(window).resize(function () {
			$("#dataGrid").datagrid("resize", {
				width: $(window).width() - 285,
				height: $(window).height() - 110
			});
		});

		$("#detailWindow").window({
			onOpen: function () {
				$(this).scrollTop(0);
			},
			top: ($(window).height() - 600) * 0.5
		});

		$("#roomWindow").window({
			onOpen: function () {
				$(this).scrollTop(0);
			},
			top: ($(window).height() - 600) * 0.5
		});

		$("#roomEditWindow").window({
			onOpen: function () {
				$(this).scrollTop(0);
			},
			top: ($(window).height() - 600) * 0.5
		});
	});

	function deleteData(id, name) {
		var confirmMessage = "@Resources.CfmDelete";
		confirmMessage = confirmMessage.replace(/\{0\}/g, name);
		$.messager.confirm("@Resources.Delete", confirmMessage, function (r) {
			if (r) {
				$("#hidID").val(id);
				$.post("@Url.Action(nameof(ConferenceHotelEditController.Delete),
						nameof(ConferenceHotelEditController).GetControllerName(), new { ConferenceId = Model.ConferenceId })",
					$("#frmDetail").serialize(),
					function(data, textStatus, jqXHR) {
						if (data.result == "@ConstValues.AjaxFailResult") {
					    		common.showError(data.message);
						} else {
					    		common.showSuccess(data.message, true);
					    		$("#dataGrid").datagrid("reload");
						}
					}
				);
			}
		});
	};

	function deleteRoomData(id, name) {
		var confirmMessage = "@Resources.CfmDelete";
		confirmMessage = confirmMessage.replace(/\{0\}/g, name);
		$.messager.confirm("@Resources.Delete", confirmMessage, function (r) {
			if (r) {
				$("#roomID").val(id);
				$.post("@Url.Action(nameof(ConferenceHotelEditController.DeleteRoom),
						nameof(ConferenceHotelEditController).GetControllerName(), new { ConferenceId = Model.ConferenceId })",
					$("#frmRoomDetail").serialize(),
					function(data, textStatus, jqXHR) {
						if (data.result == "@ConstValues.AjaxFailResult") {
							common.showError(data.message);
						} else {
							common.showSuccess(data.message, true);
							$("#roomGrid").datagrid("reload");
							$("#dataGrid").datagrid("reload");
						}
					}
				);
			}
		});
	};

	function addData() {
		$("#hdnWindowType").val("add");
		$("#detailWindowTitle").text("@Resources.Create");
		$("#txtSort").numberbox("setValue", @ConstValues.DefaultSort);
		$("#ddlStatus").combobox("setValue", "@ConstValues.Status.正常");
		$("#txtHotelName").textbox("setValue","");
		$("#txtAddress").textbox("setValue","");
		$("#txtTelephone").textbox("setValue","");
		$("#txtStarLevel").textbox("setValue","");
		$("#txtParkFee").textbox("setValue","");
		$("#txtRemark").textbox("setValue","");
		$("#detailWindow").window("open");
	}

	function addRoomData() {
		$("#hdnRoomWindowType").val("add");
		$("#roomEditWindowTitle").text("@Resources.Create");
		$("#txtRoomSort").numberbox("setValue", @ConstValues.DefaultSort);
		$("#ddlRoomStatus").combobox("setValue", "@ConstValues.Status.正常");
		$("#txtRoomType").textbox("setValue","");
		$("#txtRoomCurrency").combobox("setValue","");
		$("#txtRoomTypeBedNum").combobox({ disabled: false });
		$("#txtRoomTypeBedNum").combobox("setValue","");
		$("#txtRoomPrice1").numberbox("setValue","");
		$("#txtRoomPrice2").numberbox("setValue","");
		$("#bookingDate").datebox("setValue","");
		$("#txtRoomTotalRoomCount").numberbox("setValue","");
		$("#txtRoomRemark").textbox("setValue","");

		$("#roomEditWindow").window("open");
	}

	function editData(id) {
		var url = "@Url.Action(nameof(ConferenceHotelEditController.GetEditData),
				nameof(ConferenceHotelEditController).GetControllerName())" + "/" + id;
		$.get(url, null, function (data, textStatus, jqXHR) {
			if (data.result == "@ConstValues.AjaxFailResult") {
				common.showError(data.message);
				$("#dataGrid").datagrid("reload");
			} else {
				$("#txtHotelName").textbox("setValue",data.data.hotelName);
				$("#txtAddress").textbox("setValue",data.data.address);
				$("#txtTelephone").textbox("setValue",data.data.hotelTel);
				$("#txtStarLevel").textbox("setValue",data.data.starLevel);
				$("#txtParkFee").textbox("setValue",data.data.parkFee);
				$("#ddlStatus").combobox("setValue",data.data.status);
				$("#txtSort").numberbox("setValue", data.data.sort);
				$("#txtRemark").textbox("setValue",data.data.remark);
				$("#hidID").val(id);
				$("#hdnWindowType").val("edit");
				$("#detailWindowTitle").text("@Resources.Modify");
				$("#detailWindow").window("open");
			}
		});
	}

	function editRoomData(id) {
		$("#roomID").val(id);
		var url = "@Url.Action(nameof(ConferenceHotelEditController.GetRoomEditData),
				nameof(ConferenceHotelEditController).GetControllerName())" + "/" + id;
		$.get(url, null, function (data, textStatus, jqXHR) {
			if (data.result == "@ConstValues.AjaxFailResult") {
				common.showError(data.message);
				$("#dataGrid").datagrid("reload");
			} else {
				$("#txtRoomType").textbox("setValue",data.data.roomType),
				$("#txtRoomCurrency").combobox("setValue",data.data.currency),
				$("#txtRoomTypeBedNum").combobox({ disabled: true });
				$("#txtRoomTypeBedNum").combobox("setValue",data.data.roomBedCount);
				$("#txtRoomPrice1").numberbox("setValue",data.data.price1);;
				$("#txtRoomPrice2").numberbox("setValue",data.data.price2);
				$("#txtRoomTotalRoomCount").numberbox("setValue",data.data.totalRoomCount);
				$("#ddlRoomStatus").combobox("setValue",data.data.status);
				$("#txtRoomSort").numberbox("setValue", data.data.sort);
				$("#txtRoomRemark").textbox("setValue",data.data.remark);
				$("#bookingDate").datebox("setValue",data.data.bookDate);
				$("#hdnRoomWindowType").val("edit");
				$("#roomEditWindowTitle").text("@Resources.Modify");
				$("#roomID").val(id);
				$("#roomEditWindow").window("open");
			}
		});
	}

	function saveData() {
		var isValid = $("#frmDetail").form("validate");

		if (isValid) {
			$.messager.confirm("@Resources.Save", "@Resources.CfmSave", function (r) {
				if (r) {
					var loading = layer.load(0,  {
						shade: [0.4,"#fff"]
					});
					switch ($("#hdnWindowType").val())
					{
						case "add":
							$.post("@Url.Action(nameof(ConferenceHotelEditController.Create),
									nameof(ConferenceHotelEditController).GetControllerName(), new { ConferenceId = Model.ConferenceId })",
								$("#frmDetail").serialize(),
								function(data, textStatus, jqXHR) {
									layer.close(loading);
									if (data.result == "@ConstValues.AjaxFailResult") {
										common.showError(data.message);
									} else {
										common.showSuccess(data.message, true);
										$("#detailWindow").window("close");
										$("#dataGrid").datagrid("reload");
									}
								}
							);
							break;
						case "edit":
							$.post("@Url.Action(nameof(ConferenceHotelEditController.Modify),
									nameof(ConferenceHotelEditController).GetControllerName(), new { ConferenceId = Model.ConferenceId })",
								$("#frmDetail").serialize(),
								function(data, textStatus, jqXHR) {
									layer.close(loading);
									if (data.result == "@ConstValues.AjaxFailResult") {
										common.showError(data.message);
									} else {
										common.showSuccess(data.message, true);
										$("#detailWindow").window("close");
										$("#dataGrid").datagrid("reload");
									}
								}
							);
							break;
					}
				}
			})
		}
	};

	function saveRoomData() {
		var isValid = $("#frmRoomDetail").form("validate");

		if (isValid) {
			$.messager.confirm("@Resources.Save", "@Resources.CfmSave", function (r) {
				if (r) {
					var loading = layer.load(0,  {
						shade: [0.4,"#fff"]
					});
					switch ($("#hdnRoomWindowType").val())
					{
						case "add":
							$.post("@Url.Action(nameof(ConferenceHotelEditController.CreateRoom),
									nameof(ConferenceHotelEditController).GetControllerName(), new { ConferenceId = Model.ConferenceId })",
								$("#frmRoomDetail").serialize(),
								function(data, textStatus, jqXHR) {
									layer.close(loading);
									if (data.result == "@ConstValues.AjaxFailResult") {
										common.showError(data.message);
									} else {
										common.showSuccess(data.message, true);
										$("#roomEditWindow").window("close");
										$("#roomGrid").datagrid("reload");
										$("#dataGrid").datagrid("reload");
									}
								}
							);
							break;
						case "edit":
							$.post("@Url.Action(nameof(ConferenceHotelEditController.ModifyRoom),
									nameof(ConferenceHotelEditController).GetControllerName(), new { ConferenceId = Model.ConferenceId })",
								$("#frmRoomDetail").serialize(),
								function(data, textStatus, jqXHR) {
									layer.close(loading);
									if (data.result == "@ConstValues.AjaxFailResult") {
										common.showError(data.message);
									} else {
										common.showSuccess(data.message, true);
										$("#roomEditWindow").window("close");
										$("#roomGrid").datagrid("reload");
										$("#dataGrid").datagrid("reload");
									}
								}
							);
							break;
					}
				}
			})
		}
	};

	function roomManage(id, hotelName) {
		$("#roomGrid").datagrid({
			url: "@Url.Action(nameof(ConferenceHotelEditController.GetRoomData),
					nameof(ConferenceHotelEditController).GetControllerName())"+"?hotelId="+id,
			method: "get",
			singleSelect: true,
			nowrap: false,
			pageSize: @ConstValues.DefaultGridRows,
			striped: true,
			toolbar: "#toolBar",
			height: 532,
			frozenColumns: [[
				{ field: "id", hidden: true },
				{
					field: "operate", title: "@Resources.Operate", align: "center", width: 150,
					formatter: function(value, rec) {
						var strInfo = "";
						var tmp = rec.roomType == null ? "" : rec.roomType.replace(new RegExp("'",'g'),"’").replace(new RegExp('"','g'),"“");
						strInfo += "<a href='#' style='color:#66CDAA;font-weight:bold;text-decoration:underline;' onclick='editRoomData(\""
								+ rec.id + "\")'>@Resources.Modify</a>";
						strInfo += "&nbsp;|&nbsp;";
						strInfo += "<a href='#' style='color:#DC143C;font-weight:bold;text-decoration:underline;' onclick='deleteRoomData(\""
								+ rec.id + "\",\"" + tmp + "\")'>@Resources.Delete</a>";
						return strInfo;
					}
				},
				{ field: "roomType", title: "@Resources.RoomType", align: "center", width: 200 },
				{ field: "bookDate", title: "@Resources.ConferenceDate", align: "center", width: 200 },
			]],
			columns: [[
				{ field: "totalRoomCount", title: "@Resources.TotalRoomCount", align: "center", width: 150 },
				{ field: "leftRoomCount", title: "@Resources.LeftRoomCount", align: "center", width: 150 },
				{ field: "roomBedCount", title: "@Resources.RoomTypeBedNum", align: "center", width: 150 },
				{ field: "totalBedCount", title: "@Resources.TotalBedCount", align: "center",  width: 150 },
				{ field: "leftBedCount", title: "@Resources.LeftBedCount", align: "center",  width: 150 },
				{ field: "price1", title: "@Resources.Price1", align: "center",  width: 150 },
				{ field: "price2", title: "@Resources.Price2", align: "center",  width: 150 },
				{ field: "currency", title: "@Resources.Currency", align: "center", width: 100 },
				{
					field: "status", title: "@Resources.Status", align: "center", width: 150,
					formatter: function(value, rec) {
						if (value=="@ConstValues.Status.正常") {
							return "@Resources.Normal"
						} else {
							return "@Resources.Pause"
						}
					}
				},
				{ field: "sort", title: "@Resources.Sort", align: "center", sortable: true, width: 150},
				{ field: "remark", title: "@Resources.Remark", align: "center", sortable: true, width: 200 },
				{ field: "creator", title: "@Resources.Creator", align: "center", sortable: true, width: 150 },
				{ field: "createIP", title: "@Resources.CreateIP", align: "center", sortable: true, width: 150 },
				{ field: "createDate", title: "@Resources.CreateDate", align: "center", sortable: true, width: 150 },
			]],
			onBeforeLoad: function(param) {
				param.random = Math.random();
			}
		});
		$("#txtRoomHotelName").textbox("setValue",hotelName);
		$("#hotelID").val(id);
		$("#roomWindow").window("open");
	}

	function searchData() {
		$("#dataGrid").datagrid("load", {
			searchHotelName: $("#searchHotelName").textbox("getValue"),
		});
	}
</script>
}